//
//  ImageValueLabelStyle2.m
//  HuaRun2
//
//  Created by admin on 17/9/4.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "ImageValueLabelStyle2.h"

@implementation ImageValueLabelStyle2

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
#pragma mark - life cycle
- (void)dealloc {
NSLog(@"%@ dealloc", [self class]);
}

- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self viewInit];
[self layoutInit];
}
return self;
}

- (void)viewInit {
self.backgroundColor = kRandomColor;

[self addSubview:self.keyImageView];
[self addSubview:self.valueLab1];
[self addSubview:self.valueLab2];

}

- (void)layoutInit {
    weakself(ws);
    
    [self.keyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(ws.valueLab1);
        make.left.mas_equalTo(ws).offset(0);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    
    [self.valueLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws).offset(0);
        make.left.mas_equalTo(ws.keyImageView.mas_right).offset(kMargin10);
        make.right.mas_equalTo(ws.mas_right).offset(0);
        make.height.mas_equalTo(20);
    }];
    
    [self.valueLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.valueLab1.mas_bottom).offset(2);
        make.left.right.height.mas_equalTo(ws.valueLab1);
    }];
    
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(ws);
        make.bottom.mas_equalTo(ws.valueLab2).offset(0);
    }];
}

- (UILabel *)valueLab1 {
    if (!_valueLab1) {
        self.valueLab1 = [UILabel new];
        _valueLab1.textAlignment = NSTextAlignmentLeft;
        _valueLab1.font = kGeneralFontSize;
        _valueLab1.textColor = [UIColor colorWithHex:@"3c3c3c"];
//        _valueLab1.text = @"英文民";
        _valueLab1.backgroundColor = kRandomColor;
    }
    return _valueLab1;
}

- (UILabel *)valueLab2 {
    if (!_valueLab2) {
        self.valueLab2 = [UILabel new];
        _valueLab2.textAlignment = NSTextAlignmentLeft;
        _valueLab2.font = kGeneralFontSize;
        _valueLab2.textColor = [UIColor colorWithHex:@"3c3c3c"];
//        _valueLab2.text = @"中文名字";
    }
    return _valueLab2;
}
- (UIImageView *)keyImageView {
    if (!_keyImageView) {
        self.keyImageView = [UIImageView new];
        _keyImageView.image = [UIImage imageNamed:@"电话001"];
//        _keyImageView.backgroundColor = [UIColor greenColor];
    }
    return _keyImageView;
}
@end
